package com.zhuguohui.horizontalpage;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.zhuguohui.horizontalpage.adapter.MyAdapter;
import com.zhuguohui.horizontalpage.view.DividerItemDecoration;
import com.zhuguohui.horizontalpage.view.PagingScrollHelper;

public class MainActivity extends AppCompatActivity implements PagingScrollHelper.onPageChangeListener {
    RecyclerView recyclerView;
    MyAdapter myAdapter;
    PagingScrollHelper scrollHelper = new PagingScrollHelper();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myAdapter = new MyAdapter();
        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        recyclerView.setAdapter(myAdapter);
        scrollHelper.setUpRecycleView(recyclerView);
        scrollHelper.setOnPageChangeListener(this);
        switchLayout();
    }


    private void switchLayout() {
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
        scrollHelper.updateLayoutManger();
    }


    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    public void onPageChange(int index) {
    }
}
